package com.awesome.imagedemo.image;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.widget.ImageView;

import com.awesome.imagedemo.R;

public class ImageActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_image);
        // 默认模式（CenterCrop）
        ImageView ivDefaultLength = findViewById(R.id.iv_default_length);
        ivDefaultLength.setImageResource(R.mipmap.length_icon);

        ImageView ivDefaultWidth = findViewById(R.id.iv_default_width);
        ivDefaultWidth.setImageResource(R.mipmap.width_icon);

        // center(填满，图片大于ImageView，两侧截掉)
        ImageView ivCenterLength = findViewById(R.id.iv_center_length);
        ivCenterLength.setImageResource(R.mipmap.length_icon);

        ImageView ivCenterWidth = findViewById(R.id.iv_center_width);
        ivCenterWidth.setImageResource(R.mipmap.width_icon);

        // CenterInside(完整显示图片，图片大于ImageView，按比例缩放)
        ImageView ivCenterInsideLength = findViewById(R.id.iv_center_inside_length);
        ivCenterInsideLength.setImageResource(R.mipmap.length_icon);

        ImageView ivCenterInsideWidth = findViewById(R.id.iv_center_inside_width);
        ivCenterInsideWidth.setImageResource(R.mipmap.width_icon);

        // CenterCrop(填满，图片大于ImageView，一侧完全显示，一侧截掉)
        ImageView ivCenterCropLength = findViewById(R.id.iv_center_crop_length);
        ivCenterCropLength.setImageResource(R.mipmap.length_icon);

        ImageView ivCenterCropWidth = findViewById(R.id.iv_center_crop_width);
        ivCenterCropWidth.setImageResource(R.mipmap.width_icon);

        // fitXY
        ImageView ivFitXYLength = findViewById(R.id.iv_fit_xy_length);
        ivFitXYLength.setImageResource(R.mipmap.length_icon);

        ImageView ivFitXYWidth = findViewById(R.id.iv_fit_xy_width);
        ivFitXYWidth.setImageResource(R.mipmap.width_icon);
    }
}